package datasv.framework_datasv;

import data.datafactory.DatabaseOperator;
import po.SubModelPO;

public class GetSubModel {
	public static void main(String[] args) {
		System.out.println(new GetSubModel().getSubModel("000", "00001", "000000101"));
	}
	public SubModelPO getSubModel(String collegeID,String modelID,String subModelID){
		return getInSql(collegeID, modelID, subModelID);
	}
	private SubModelPO getInSql(String collegeID,String modelID,String subModelID){
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
		modelID=subModelID.substring(0,7);
		if(!op.ifDatabaseExist()||!op.ifFormExist("plan_submodel_list_"+modelID)){
			return null;
		}
		String category=op.getOneInform(subModelID, "plan_submodel_list_"+modelID, "category");
	//	category=op.getOneInform(category, "category_list", "name");
		String name=op.getOneInform(subModelID, "plan_submodel_list_"+modelID, "name");
		int hS=Integer.parseInt(op.getOneInform(subModelID, "plan_submodel_list_"+modelID, "headSemester"));
		int tS=Integer.parseInt(op.getOneInform(subModelID, "plan_submodel_list_"+modelID, "tailSemester"));
		int headCredit=Integer.parseInt(op.getOneInform(subModelID, "plan_submodel_list_"+modelID, "headCredit"));
		int tailCredit=Integer.parseInt(op.getOneInform(subModelID, "plan_submodel_list_"+modelID, "tailCredit"));
		return new SubModelPO(subModelID, category, name, hS, tS, headCredit, tailCredit);
	}

}
